package qldc.pm.tienan.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import qldc.pm.tienan.model.DoiTuongTienAn;
import qldc.pm.tienan.model.DoiTuongTienAnModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the DoiTuongTienAn service. Represents a row in the &quot;TA_DoiTuongTienAn&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link qldc.pm.tienan.model.DoiTuongTienAnModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DoiTuongTienAnImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see DoiTuongTienAnImpl
 * @see qldc.pm.tienan.model.DoiTuongTienAn
 * @see qldc.pm.tienan.model.DoiTuongTienAnModel
 * @generated
 */
public class DoiTuongTienAnModelImpl extends BaseModelImpl<DoiTuongTienAn>
    implements DoiTuongTienAnModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a doi tuong tien an model instance should use the {@link qldc.pm.tienan.model.DoiTuongTienAn} interface instead.
     */
    public static final String TABLE_NAME = "TA_DoiTuongTienAn";
    public static final Object[][] TABLE_COLUMNS = {
            { "doiTuongTienAnId", Types.BIGINT },
            { "userId", Types.BIGINT },
            { "userName", Types.VARCHAR },
            { "createDate", Types.TIMESTAMP },
            { "modifiedDate", Types.TIMESTAMP },
            { "soDinhDanhCaNhan", Types.VARCHAR },
            { "xoaAnTich", Types.BOOLEAN }
        };
    public static final String TABLE_SQL_CREATE = "create table TA_DoiTuongTienAn (doiTuongTienAnId LONG not null primary key,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,soDinhDanhCaNhan VARCHAR(75) null,xoaAnTich BOOLEAN)";
    public static final String TABLE_SQL_DROP = "drop table TA_DoiTuongTienAn";
    public static final String ORDER_BY_JPQL = " ORDER BY doiTuongTienAn.createDate ASC";
    public static final String ORDER_BY_SQL = " ORDER BY TA_DoiTuongTienAn.createDate ASC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.qldc.pm.tienan.model.DoiTuongTienAn"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.qldc.pm.tienan.model.DoiTuongTienAn"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.qldc.pm.tienan.model.DoiTuongTienAn"),
            true);
    public static long SODINHDANHCANHAN_COLUMN_BITMASK = 1L;
    public static long CREATEDATE_COLUMN_BITMASK = 2L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.qldc.pm.tienan.model.DoiTuongTienAn"));
    private static ClassLoader _classLoader = DoiTuongTienAn.class.getClassLoader();
    private static Class<?>[] _escapedModelInterfaces = new Class[] {
            DoiTuongTienAn.class
        };
    private long _doiTuongTienAnId;
    private long _userId;
    private String _userUuid;
    private String _userName;
    private Date _createDate;
    private Date _modifiedDate;
    private String _soDinhDanhCaNhan;
    private String _originalSoDinhDanhCaNhan;
    private Boolean _xoaAnTich;
    private long _columnBitmask;
    private DoiTuongTienAn _escapedModel;

    public DoiTuongTienAnModelImpl() {
    }

    @Override
    public long getPrimaryKey() {
        return _doiTuongTienAnId;
    }

    @Override
    public void setPrimaryKey(long primaryKey) {
        setDoiTuongTienAnId(primaryKey);
    }

    @Override
    public Serializable getPrimaryKeyObj() {
        return _doiTuongTienAnId;
    }

    @Override
    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    @Override
    public Class<?> getModelClass() {
        return DoiTuongTienAn.class;
    }

    @Override
    public String getModelClassName() {
        return DoiTuongTienAn.class.getName();
    }

    @Override
    public Map<String, Object> getModelAttributes() {
        Map<String, Object> attributes = new HashMap<String, Object>();

        attributes.put("doiTuongTienAnId", getDoiTuongTienAnId());
        attributes.put("userId", getUserId());
        attributes.put("userName", getUserName());
        attributes.put("createDate", getCreateDate());
        attributes.put("modifiedDate", getModifiedDate());
        attributes.put("soDinhDanhCaNhan", getSoDinhDanhCaNhan());
        attributes.put("xoaAnTich", getXoaAnTich());

        return attributes;
    }

    @Override
    public void setModelAttributes(Map<String, Object> attributes) {
        Long doiTuongTienAnId = (Long) attributes.get("doiTuongTienAnId");

        if (doiTuongTienAnId != null) {
            setDoiTuongTienAnId(doiTuongTienAnId);
        }

        Long userId = (Long) attributes.get("userId");

        if (userId != null) {
            setUserId(userId);
        }

        String userName = (String) attributes.get("userName");

        if (userName != null) {
            setUserName(userName);
        }

        Date createDate = (Date) attributes.get("createDate");

        if (createDate != null) {
            setCreateDate(createDate);
        }

        Date modifiedDate = (Date) attributes.get("modifiedDate");

        if (modifiedDate != null) {
            setModifiedDate(modifiedDate);
        }

        String soDinhDanhCaNhan = (String) attributes.get("soDinhDanhCaNhan");

        if (soDinhDanhCaNhan != null) {
            setSoDinhDanhCaNhan(soDinhDanhCaNhan);
        }

        Boolean xoaAnTich = (Boolean) attributes.get("xoaAnTich");

        if (xoaAnTich != null) {
            setXoaAnTich(xoaAnTich);
        }
    }

    @Override
    public long getDoiTuongTienAnId() {
        return _doiTuongTienAnId;
    }

    @Override
    public void setDoiTuongTienAnId(long doiTuongTienAnId) {
        _doiTuongTienAnId = doiTuongTienAnId;
    }

    @Override
    public long getUserId() {
        return _userId;
    }

    @Override
    public void setUserId(long userId) {
        _userId = userId;
    }

    @Override
    public String getUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
    }

    @Override
    public void setUserUuid(String userUuid) {
        _userUuid = userUuid;
    }

    @Override
    public String getUserName() {
        if (_userName == null) {
            return StringPool.BLANK;
        } else {
            return _userName;
        }
    }

    @Override
    public void setUserName(String userName) {
        _userName = userName;
    }

    @Override
    public Date getCreateDate() {
        return _createDate;
    }

    @Override
    public void setCreateDate(Date createDate) {
        _columnBitmask = -1L;

        _createDate = createDate;
    }

    @Override
    public Date getModifiedDate() {
        return _modifiedDate;
    }

    @Override
    public void setModifiedDate(Date modifiedDate) {
        _modifiedDate = modifiedDate;
    }

    @Override
    public String getSoDinhDanhCaNhan() {
        if (_soDinhDanhCaNhan == null) {
            return StringPool.BLANK;
        } else {
            return _soDinhDanhCaNhan;
        }
    }

    @Override
    public void setSoDinhDanhCaNhan(String soDinhDanhCaNhan) {
        _columnBitmask |= SODINHDANHCANHAN_COLUMN_BITMASK;

        if (_originalSoDinhDanhCaNhan == null) {
            _originalSoDinhDanhCaNhan = _soDinhDanhCaNhan;
        }

        _soDinhDanhCaNhan = soDinhDanhCaNhan;
    }

    public String getOriginalSoDinhDanhCaNhan() {
        return GetterUtil.getString(_originalSoDinhDanhCaNhan);
    }

    @Override
    public Boolean getXoaAnTich() {
        return _xoaAnTich;
    }

    @Override
    public void setXoaAnTich(Boolean xoaAnTich) {
        _xoaAnTich = xoaAnTich;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
            DoiTuongTienAn.class.getName(), getPrimaryKey());
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        ExpandoBridge expandoBridge = getExpandoBridge();

        expandoBridge.setAttributes(serviceContext);
    }

    @Override
    public DoiTuongTienAn toEscapedModel() {
        if (_escapedModel == null) {
            _escapedModel = (DoiTuongTienAn) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
        }

        return _escapedModel;
    }

    @Override
    public Object clone() {
        DoiTuongTienAnImpl doiTuongTienAnImpl = new DoiTuongTienAnImpl();

        doiTuongTienAnImpl.setDoiTuongTienAnId(getDoiTuongTienAnId());
        doiTuongTienAnImpl.setUserId(getUserId());
        doiTuongTienAnImpl.setUserName(getUserName());
        doiTuongTienAnImpl.setCreateDate(getCreateDate());
        doiTuongTienAnImpl.setModifiedDate(getModifiedDate());
        doiTuongTienAnImpl.setSoDinhDanhCaNhan(getSoDinhDanhCaNhan());
        doiTuongTienAnImpl.setXoaAnTich(getXoaAnTich());

        doiTuongTienAnImpl.resetOriginalValues();

        return doiTuongTienAnImpl;
    }

    @Override
    public int compareTo(DoiTuongTienAn doiTuongTienAn) {
        int value = 0;

        value = DateUtil.compareTo(getCreateDate(),
                doiTuongTienAn.getCreateDate());

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof DoiTuongTienAn)) {
            return false;
        }

        DoiTuongTienAn doiTuongTienAn = (DoiTuongTienAn) obj;

        long primaryKey = doiTuongTienAn.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        DoiTuongTienAnModelImpl doiTuongTienAnModelImpl = this;

        doiTuongTienAnModelImpl._originalSoDinhDanhCaNhan = doiTuongTienAnModelImpl._soDinhDanhCaNhan;

        doiTuongTienAnModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<DoiTuongTienAn> toCacheModel() {
        DoiTuongTienAnCacheModel doiTuongTienAnCacheModel = new DoiTuongTienAnCacheModel();

        doiTuongTienAnCacheModel.doiTuongTienAnId = getDoiTuongTienAnId();

        doiTuongTienAnCacheModel.userId = getUserId();

        doiTuongTienAnCacheModel.userName = getUserName();

        String userName = doiTuongTienAnCacheModel.userName;

        if ((userName != null) && (userName.length() == 0)) {
            doiTuongTienAnCacheModel.userName = null;
        }

        Date createDate = getCreateDate();

        if (createDate != null) {
            doiTuongTienAnCacheModel.createDate = createDate.getTime();
        } else {
            doiTuongTienAnCacheModel.createDate = Long.MIN_VALUE;
        }

        Date modifiedDate = getModifiedDate();

        if (modifiedDate != null) {
            doiTuongTienAnCacheModel.modifiedDate = modifiedDate.getTime();
        } else {
            doiTuongTienAnCacheModel.modifiedDate = Long.MIN_VALUE;
        }

        doiTuongTienAnCacheModel.soDinhDanhCaNhan = getSoDinhDanhCaNhan();

        String soDinhDanhCaNhan = doiTuongTienAnCacheModel.soDinhDanhCaNhan;

        if ((soDinhDanhCaNhan != null) && (soDinhDanhCaNhan.length() == 0)) {
            doiTuongTienAnCacheModel.soDinhDanhCaNhan = null;
        }

        doiTuongTienAnCacheModel.xoaAnTich = getXoaAnTich();

        return doiTuongTienAnCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(15);

        sb.append("{doiTuongTienAnId=");
        sb.append(getDoiTuongTienAnId());
        sb.append(", userId=");
        sb.append(getUserId());
        sb.append(", userName=");
        sb.append(getUserName());
        sb.append(", createDate=");
        sb.append(getCreateDate());
        sb.append(", modifiedDate=");
        sb.append(getModifiedDate());
        sb.append(", soDinhDanhCaNhan=");
        sb.append(getSoDinhDanhCaNhan());
        sb.append(", xoaAnTich=");
        sb.append(getXoaAnTich());
        sb.append("}");

        return sb.toString();
    }

    @Override
    public String toXmlString() {
        StringBundler sb = new StringBundler(25);

        sb.append("<model><model-name>");
        sb.append("qldc.pm.tienan.model.DoiTuongTienAn");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>doiTuongTienAnId</column-name><column-value><![CDATA[");
        sb.append(getDoiTuongTienAnId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userId</column-name><column-value><![CDATA[");
        sb.append(getUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userName</column-name><column-value><![CDATA[");
        sb.append(getUserName());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>createDate</column-name><column-value><![CDATA[");
        sb.append(getCreateDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
        sb.append(getModifiedDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>soDinhDanhCaNhan</column-name><column-value><![CDATA[");
        sb.append(getSoDinhDanhCaNhan());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>xoaAnTich</column-name><column-value><![CDATA[");
        sb.append(getXoaAnTich());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
